package com.irving;

import java.lang.reflect.Constructor;

public class ReflectSingleton {

    public static void main(String[] args) {
        Class clazz = StaticSingleton.class;

        try {
            Constructor constructor = clazz.getDeclaredConstructor(null);
            constructor.setAccessible(true);
            StaticSingleton s1 = (StaticSingleton) constructor.newInstance();
            StaticSingleton s2 = (StaticSingleton) constructor.newInstance();

            System.out.println(s1);
            System.out.println(s2);
            System.out.println(s1 == s2);

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
